package com.qing.demo.netty.demo1.nio.client;

import com.qing.demo.netty.demo1.nio.ChannelAdapter;
import com.qing.demo.netty.demo1.nio.ChannelHandler;

import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

/**
 * @author caozhipeng
 * @date 2025/7/22
 */
public class NioClientHandler extends ChannelAdapter {
    public NioClientHandler(Selector selector, Charset charset) {
        super(selector, charset);
    }

    @Override
    public void channelActive(ChannelHandler channelHandler) {
        System.out.println("客户端连接成功");
        channelHandler.writeAndFlush("hello world\r\n");
    }

    @Override
    public void channelRead(ChannelHandler channelHandler, Object msg) {
        System.out.println("客户端接收信息："+msg+" \r\n");
        channelHandler.writeAndFlush("客户端信息处理success \r\n");
    }

}
